from jili.calc import calcor_base
import numpy as np
class signal_merge(calcor_base):
    def __init__(self,ta_arg={}):
        self.out = ["s"]
        self.input = ["close"]
        self.parameters = {"timeperiod":2}
        super().__init__(ta_arg)
        self.batch=self.parameters["timeperiod"]
        self.lookback = self.batch - 1
    def calc(self):
        is1=[]
        is2=[]
        for v in self.hisbars.values():
            i20=-2 in v
            i21=2 in v
            is1.append(i20)
            is2.append(i21)
        if False not in  is1:
            return -2
        elif False not in  is2:
            return 2
        else:
            return 0